<template>
  <div class="home">
    <h1>{{count}}</h1>
    <!-- <h1>{{this.$store.state.count}}</h1> -->
    <button @click="add">++</button>
    <button @click="dec">--</button>
    <!-- <h3>{{this.$store.getters.mul}}</h3> -->
    <h3>{{mul}}</h3>
  </div>
</template>

<script>
  export default {
    mounted() {
      console.log(this);
    },
    data() {
      return {
        // count: 0
      }
    },
    computed: {
      count() {
        return this.$store.state.count;
      },
      mul() {
        return this.$store.getters.mul;
      }
    },
    methods: {
      add() {
        // this.count++;
        // this.$store.state.count++;
        /*
          参数1:action中方法名
          参数2:普通参数
        */
        this.$store.dispatch('jiaA', 2);
      },
      dec() {
        // this.count--;
        // this.$store.state.count--;
        this.$store.commit('jianM', 6);
      }
    }
  }
</script>
